<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>context</title>
</head>
<body>
    <div id="app"></div>
</body>
<script src="https://unpkg.com/vue@next"></script>
<script>
    const app = Vue.createApp({
        template: `<div>
            <component-demo></component-demo>
            </div>`,
            setup(props){
                function handleClick(){
                    alert("hello vue.js!!!!!! ")
                }
                return {handleClick}
            }
    })

    app.component('component-demo', {
        setup(props, context) {
            const { h } =Vue;
            const { attrs, slots, emit } = context;
            //attrs 获取None-Porp对象
            console.log('attrs.title = ',attrs.title)

            //slots插槽
            console.log('slots = ',slots.default())
            //return () => h('div',{},'123');
            //return () =>h('div',{},slots.default());

            //emit,子组件传播事件
            console.log('emit = ',emit)
            function handleClick(){
                emit('change')
            }
            return {handleClick}
        },
        template: `
            <div> child </div>
        `
    })

    const vm = app.mount("#app")
</script>
</html>